package ruan_kao;

class Matrix {//各种格式的文件最终都被转化为像素矩阵
    //此处代码省略
}

abstract class Implementor {
    public abstract void doPaint(Matrix m); //1
}

class WinImp extends Implementor {
    public void doPaint(Matrix m) {
        //调用Windows系统的绘制函数绘制像素矩阵
    }
}

class LinuxImp extends Implementor {
    public void doPaint(Matrix m) {
        //调用Linux系统的绘制函数绘制像素矩阵
    }
}

abstract class Image {
    public void setImp(Implementor imp) {
        this.imp = imp;
    }

    public abstract void parseFile(String fileName);

    protected Implementor imp;
}

//class BMPImage extends Image {
//    //此处代码省略
//}

class GIFImage extends Image {
    public void parseFile(String fileName) {
        Matrix m = new Matrix(); //此处解析BMP文件并获得一个像素矩阵对象m
        imp.doPaint(m);//显示像素矩阵m 2
    }
}

class Main {
    public static void main(String[] args) {
        Image image = new GIFImage(); //3
        Implementor imageImp = new LinuxImp(); //4
        image.setImp(imageImp); //5
        image.parseFile("demo.gif");
    }
}
